<template>
   <div style="width: 50%;margin-left: 50px">

     <el-form :inline="false" :model="formData1" class="demo-form-inline">
       <el-form-item label="合同名称">
         <el-input v-model="formData1.title" placeholder="合同名称"></el-input>
       </el-form-item>
       <el-form-item label="合同内容">
         <el-input type="textarea" :rows="10"  placeholder="合同内容" v-model="formData1.content"></el-input>
       </el-form-item>
       <el-form-item label="甲方代表">
         <el-input v-model="formData1.jiafang" placeholder="甲方代表"></el-input>
       </el-form-item>
       <el-form-item label="乙方代表">
         <el-input v-model="formData1.yifang" placeholder="乙方代表"></el-input>
       </el-form-item>
       <el-form-item label="日期">
         <el-date-picker v-model="formData1.riqi" format="yyyy-MM-dd HH:mm:ss"
                         value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择签署日期时间"></el-date-picker>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" @click="saveHt">提交生成合同</el-button>
       </el-form-item>
     </el-form>

     <el-button type="primary" @click="xiazaiht"  v-show="isshow">下载合同</el-button>
     <el-button type="primary" @click="yulan"  v-show="isshow">预览合同</el-button>


     <h1>================================================================================</h1>

     <el-form :inline="false" :model="formData2" class="demo-form-inline">
       <el-form-item label="合同code">
         <el-input v-model="formData2.htcode" placeholder="合同code"></el-input>
       </el-form-item>

       <el-form-item>
         <el-button type="primary" @click="renzheng" >认证合同</el-button>
       </el-form-item>
     </el-form>



   </div>
</template>

<script>
    import {shenfenzheng} from '../../store/yanzheng'
    export default {
        name: "hetong",
        data(){
           return{
             isshow:false,
             myhref:"",
             htcode:"",
             xiazai:this.$myInfo.loginPath+'xiazai'+"?htcode="+this.htcode,
             formData1:{
                 title:"",
               content:"",
               jiafang:"",
               yifang:"",
               riqi:""
             },
             formData2:{
               htcode:""
             }
           }
        },
        methods:{
          //认证合同
          renzheng(){
            this.$axios.get(this.$myInfo.loginPath+"renzhengHetong?htcode="+this.formData2.htcode).then((response)=>{
               alert(JSON.stringify(response.data))
            })
          },
          //下载合同
          xiazaiht(){
            window.location.href=this.$myInfo.loginPath+"xiazai/"+this.htcode;
          },
          yulan(){
            window.location.href=this.myhref;
          },
          //保存合同
          saveHt(){

            const loading = this.$loading({ lock: true,text: '数据提交中，请等待！！',spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)'});
            this.$axios.post(this.$myInfo.loginPath+"saveHt",this.formData1).then((response)=>{
                 if(response.data.code==200){
                   let  pdfminiopath=response.data.result.filePath;
                   this.htcode=response.data.result.htcode;
                   this.isshow=true;
                   //pdf在minio的路径用来做预览
                   this.myhref=pdfminiopath;

                   alert(this.htcode);
                   loading.close();
                   //提示一下成功
                   this.$message({type:"success",message:"保存成功"})
                 }else{
                   //提示失败
                   this.$message({type:"error",message:response.data.result})
                   loading.close();
                 }

            })
          }
        }
    }
</script>

<style scoped>

</style>
